
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Testing extends JFrame
{
  MyDesktopPane dp = new MyDesktopPane();
  JInternalFrame if1 = new JInternalFrame( "I-F1", true, true, true, true );
  JInternalFrame if2 = new JInternalFrame( "I-F2", true, true, true, true );
  JTextField[] tf = new JTextField[4];
  JButton[] btn = new JButton[tf.length];
  public Testing()
  {
    setLocation(300,200);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel1 = new JPanel(new GridLayout(4,1));
    JPanel panel2 = new JPanel(new GridLayout(4,1));
    for(int x = 0; x < tf.length; x++)
    {
      tf[x] = new JTextField(5);
      panel1.add(tf[x]);
      btn[x] = new JButton("B"+(x+1));
      panel2.add(btn[x]);
    }
    if1.setLocation(50,50);
    if2.setLocation(250,50);
    if1.getContentPane().add(panel1);
    if2.getContentPane().add(panel2);
    if1.pack();
    if2.pack();
    if1.setVisible(true);
    if2.setVisible(true);
    dp.add(if1);
    dp.add(if2);
    getContentPane().add(dp);
    setSize(400,300);
    setVisible(true);
  }
  public static void main(String[] args){new Testing();}
}
class MyDesktopPane extends JDesktopPane
{
  Image img;
  public MyDesktopPane()
  {
    try
    {
      img = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Water lilies.jpg"), "Water lilies.jpg"));
    }
    catch(Exception e){}//do nothing
  }
  public void paintComponent(Graphics g)
  {
    super.paintComponent(g);
    if(img != null) g.drawImage(img, 0,0,this.getWidth(),this.getHeight(),this);
    else g.drawString("Image not found", 50,50);
  }
}

